const jdGetAxios = require('../modules/axios').jdGetAxios;
const schedule = require("node-schedule");
class GetAmoyListSchedule {
    /**
     * 间隔时间触发url
     * @param {second,minute,hour,date,dayOfWeek,month,year} ruleJson 
     * @param {*} url 
     */
    static schedule(ruleJson, url) {
        let rule = new schedule.RecurrenceRule();
        rule = ruleJson;
        schedule.scheduleJob(rule, function () {
            jdGetAxios(url).then(function (data) {
                console.log(data)
            });
            console.log('已触发');
        })
    }
    /**
     * 固定时间触发（只执行一次，时间过，就不会再执行）
     * @param {固定时间} date 
     */
    static scheduleFixed(date) {
        schedule.scheduleJob(date, function () {
            console.log("执行任务");
        });
    }
}
let url = 'http://127.0.0.1:3908';
GetAmoyListSchedule.schedule({ "minute": [10, 40,55,56] }, `http://www.baidu.com`);
//GetAmoyListSchedule.scheduleFixed(new Date(2019, 10, 15, 23, 18, 0));
module.exports = GetAmoyListSchedule;
